package com.jerry.db.service;

import com.jerry.db.dao.BootRolePermissionMapper;
import com.jerry.db.dao.BootUserInfoMapper;
import com.jerry.db.domain.BootRolePermission;
import com.jerry.db.domain.BootRolePermissionExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
public class BootPermissionInfoService {
    @Resource
    private BootRolePermissionMapper  bootRolePermissionMapper;

   public Set<String> queryByRoleIds(String[] roldIds){

        Set<String> permissions = new HashSet<>();
        BootRolePermissionExample bootRolePermissionExample = new BootRolePermissionExample();
        bootRolePermissionExample.or().andRoleIdIn(Arrays.asList(roldIds)).andIsDelEqualTo(false);
        List<BootRolePermission> bootRolePermissionList =  bootRolePermissionMapper.selectByExample(bootRolePermissionExample);
        for(BootRolePermission bootRolePermission:bootRolePermissionList){

            permissions.add(bootRolePermission.getPermissionName());
        }
        return  permissions;
    }
}
